package com.leyou.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.item.dto.SpecParamDTO;
import com.leyou.item.entity.SpecParam;
import com.leyou.item.mapper.SpecParamMapper;
import com.leyou.item.service.SpecParamService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SpecParamServiceImpl extends ServiceImpl<SpecParamMapper, SpecParam> implements SpecParamService {
    @Override
    public List<SpecParamDTO> querySpecParams(Long gid, Long cid, Boolean searching) {

        List<SpecParam> specParams = this.query().eq(null != gid, "group_Id", gid)
                .eq(null != cid, "category_id", cid).list();
        return SpecParamDTO.convertEntityList(specParams);
    }

    @Override
    public void addSpecParam(SpecParamDTO specParamDTO) {
        save(specParamDTO.toEntity(SpecParam.class));
    }

    @Override
    public void updateSpecParam(SpecParamDTO specParamDTO) {
        updateById(specParamDTO.toEntity(SpecParam.class));
    }
}